package hellow_grails

import grails.converters.JSON
import groovy.sql.Sql
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.context.properties.ConfigurationProperties

import javax.sql.DataSource

@ConfigurationProperties("test")
class NoticeController {

    NoticeService noticeService

    @Autowired
    MyBean myBean

    @Autowired
    DataSource dataSource

    def value

//    static allowedMethods = [index: "GET"]

    def index() {
        println new Sql(dataSource: dataSource)
        println params.id
        println params
        println myBean
        render noticeService.getNoticeList().collect() {
            [
                    userId: it.userId,
                    createdTs: it.createdTs,
            ]
        } as JSON
    }

    def search1() {
        println value
        println myBean
        render 'search1'
    }

    def search2() {
        println myBean
        render 'search2'
    }
}
